using System;
using System.Collections.Generic;
using System.Data;
using DotNetNuke.Framework;
using gdlmo.DNN.Modules.Dept.Data;

namespace gdlmo.DNN.Modules.Dept.Business
{
	public class DeptController : DotNetNuke.Entities.Modules.ISearchable, DotNetNuke.Entities.Modules.IPortable
	{
		#region "Public Methods"		
		public DeptInfo Get(int DeptId,int moduleId )
		{
			return (DeptInfo)DotNetNuke.Common.Utilities.CBO.FillObject(DataProvider.Instance().GetDept(DeptId), typeof(DeptInfo));
		}

        public List<DeptInfo> GetDepts(int ModuleId)
        {            
            return GetDepts(ModuleId, 0);
        }

        public List<DeptInfo> GetDepts(int ModuleId, int ParentId)
		{
            return DotNetNuke.Common.Utilities.CBO.FillCollection<DeptInfo>(DataProvider.Instance().GetDepts(ModuleId, ParentId));
		}
       
		public int Add(DeptInfo objDept)
		{
			return (int)DataProvider.Instance().AddDept(objDept.ModuleId, objDept.DeptName, objDept.Description, objDept.ParentId, objDept.ViewOrder, objDept.IsActive, objDept.CreatedByUser);
		}
	
		public void Update(DeptInfo objDept)
		{
			DataProvider.Instance().UpdateDept(objDept.DeptId, objDept.ModuleId, objDept.DeptName, objDept.Description, objDept.ParentId, objDept.ViewOrder, objDept.IsActive, objDept.CreatedByUser);
		}
		
		public void Delete(int DeptId)
		{
			DataProvider.Instance().DeleteDept(DeptId);
		}
		#endregion

		#region "Optional Interfaces"		
        public DotNetNuke.Services.Search.SearchItemInfoCollection GetSearchItems(DotNetNuke.Entities.Modules.ModuleInfo ModInfo)
		{
			return null;
		}
	
        public string ExportModule(int ModuleID)
		{
			return "";
        }

        public void ImportModule(int ModuleID, string Content, string Version, int UserId)
		{
		}
		#endregion
	}
}
